home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-09-20 | 3.7 KB | 138 lines | [TEXT/MPS ] |
-
-
-
- FUNCTION Make14RedPalette: PaletteHandle;
- VAR
- i: LONGINT;
- ph: PaletteHandle;
- c: RGBColor;
-
- BEGIN
- ph := NewPalette(14,NIL,pmTolerant,4000);
- { 4000 is about 1/16 of 64k *)
- { should check for NIL result *)
-
- c.green := 0;
- c.blue := 0;
-
- FOR i:= 0 TO 13
- DO
- BEGIN
- { range red component from 1/14 to 14/14 *)
- { i is a longint, and so can safely be multiplied by 65535 *)
- c.red := (i+1)*65535 DIV 14;
- SetEntryColor(ph,i,c);
- END;
-
- Make14RedPalette := ph;
- END;
-
-
- myPalette := Make14RedPalette;
- SetPalette(myWindow,myPalette);
-
-
-
-
- FUNCTION MakeRedPalette: PaletteHandle;
- VAR
- i: LONGINT;
- ph: PaletteHandle;
- c: RGBColor;
-
- BEGIN
- ph := NewPalette(254+14,NIL,0,0);
- { should check for NIL result *)
-
- c.green := 0;
- c.blue := 0;
-
- { Make fourteen reds that are inhibited on all *)
- { screens except four-bit color *)
- FOR i:=0 TO 13
- DO
- BEGIN
- { range red component from 1/14 to 14/14 *)
- { i is a longint, and so can safely be multiplied by 65535 *)
- c.red := (i+1)*65535 DIV 14;
- SetEntryColor(ph,i,c);
- SetEntryUsage(ph,i,pmTolerant+pmInhibitC2+
- pmInhibitG2+pmInhibitG4+
- pmInhibitC8+pmInhibitG8,4000);
- END;
-
- { Make 254 reds that are inhibited on all *)
- { screens except eight-bit color *)
- FOR i:=0 TO 254
- DO
- BEGIN
- { range red component from 1/14 to 14/14 *)
- { i is a longint, and so can safely be multiplied by 65535 *)
- c.red := (i+1)*65535 DIV 254;
- SetEntryColor(ph,14+i,c);
- SetEntryUsage(ph,14+i,pmTolerant+pmInhibitC2+
- pmInhibitG2+pmInhibitG4+
- pmInhibitC4+pmInhibitG8,0);
- END;
-
- MakeRedPalette := ph;
- END;
-
-
-
- SetEntryUsage(ph,1,pmCourteous,0);
- { The color is “courteous,” activating the palette will never *)
- { cause a change in a screen’s color table. This is useful only *)
- { for “naming” the color, in this case to 1. PmForeColor(1) and *)
- { PmBackColor(1) are two ways to use this color. *)
-
- SetEntryUsage(ph,2,pmTolerant,10000);
- { The color is “tolerant,” activating the palette will ensure *)
- { some index in the screen’s color table is within 10000 in each *)
- { RGB component from palette entry 2. *)
-
- SetEntryUsage(ph,3,pmAnimated,0);
- { The color is “animated,” activating the palette will reserve *)
- { an index from the screen’s color table to be owned by this *)
- { palette (if the screen is indexed). If the color is changed *)
- { with AnimateEntry then any previous drawing done with that *)
- { entry will change. *)
-
- SetEntryUsage(ph,4,pmExplicit,0);
- { The color is “explicit,” any drawing done with this entry will *)
- { draw in device index 4, because this entry is the 4th color *)
- { in the palette. This is mostly useful for monitoring the color *)
- { environment. *)
-
- SetEntryUsage(ph,5,pmExplicit+pmTolerant,0);
- { The color is both “explicit” and “tolerant.” Activating the *)
- { palette will ensure that device index 5 exactly matches *)
- { the palette’s color 5 (because the tolerance here is 0). *)
-
- SetEntryUsage(ph,6,pmExplicit+pmAnimated,0);
- { The color is both “explicit” and “animated.” Activating the *)
- { palette will reserve screen index 6 for this palette’s use. *)
- { The color may be modified with AnimateEntry and *)
- { AnimatePalette. *)
-
- SetEntryUsage(ph,7,pmAnimated+pmInhibitC8+pmInhibitG8,0);
- { The color is “animated” on any screen other than an 8-bit *)
- { color or an 8-bit gray-scale device. On those devices, the *)
- { behaves as a courteous color. *)
-
-
-
-
-
- myPP: PixPatHandle;
- myCT: CTabHandle;
-
- myPP := GetPixPat(16); { Gets the system color desktop pattern *)
- myCT := myPP^^.patMap^^.pmTable
- FOR j := 0 TO myCT^^.ctSize
- DO
- myCT^^.ctTable[j].value := j;
-
- myCT^^.ctFlags := myCT^^.ctFlags+$4000; { .ctFlags aka .transinde *)
- { would be bad if bit 14 were already set *)
-